package com.xukang.batch.controller.listener;

import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;

/**
 * 自定义执行监听器
 */
@Component
public class MyExecutionListener implements ExecutionListener {

    @Override
    public void notify(DelegateExecution execution) {
        // 获取流程变量
        String processInstanceId = execution.getProcessInstanceId();
        String eventName = execution.getEventName(); // start, end, take
        if (EVENTNAME_START.equals(eventName)) {

        } else if (EVENTNAME_TAKE.equals(eventName)) {

        } else if (EVENTNAME_END.equals(eventName)) {

        }
        // 执行自定义逻辑
        System.out.println("执行监听器触发: 流程实例ID=" + processInstanceId + ", 事件=" + eventName);

        // 设置流程变量
        execution.setVariable("listenerExecuted", true);
    }
}